$(function () {
  // 绑定显示化妆品类的商品
  fillProductList($("#cosmetic-list"), 548);
  // 绑定家居用品
  fillProductList($("#house-use-list"), 628);
});

function fillProductList($selectorId, id) {
  let url = "front/product.do?action=typeOneList&typeOneId=" + id;
  $.get(url, function (result) {
    if (result.code == "00000") {
      let productList = result.data;
      for (let i = 0; i < productList.length; i++) {
        let li = `
              <li>
                <a href="front/product.do?action=detail&id=${productList[i].id}">
                  <p><img src="assets/upload/${productList[i].fileName}" width="185px" height="155px"></p>
                  <p>${productList[i].name}</p>
                  <p>${productList[i].price}元</p>
                  <p><a href="front/shoppingCart.do?action=add&productId=${productList[i].id}"><img src="assets/images/cart.jpg" alt="购物车" title="加入到购物车"></a></p>
                </a>
              </li>
          `;
        $selectorId.append(li);
      }
    } else {
      console.log(result.errorMessage);
    }
  }, "json");
}